<?
    /* -*- Mode: PHP5; tab-width: 4; indent-tabs-mode: nil; basic-offset: 4 -*- */
    
    /*********************************************************
    *            --== InArch ==--
    *
    * Ajax Drop Node
    *
    * @author Kulikov Alexey <a.kulikov@gmail.com>
    * @version n/a
    * @since 06.06.2005
    * @copyright essentialmind.com 2005
    *
    *********************************************************/

    /***
    * class ajaxDeleteGroup
    ****
    * This class will delete a group from the system, please note
    * that system groups (id 1, 1000) cannot be deleted
    ****
    * @package ajax
    * @author A Kulikov <a.kulikov@gmail.com>
    * @version n/a
    * @since 06.06.2005
    * @copyright essentialmind.com 2005
    ***/
    class ajaxDeleteGroup extends ajaxAction{

        public function process(){
            //try to drop the node
            try{
               //make sure the ID is valid
               $id = (int)$_REQUEST['id'];
               
               if($id == 1 or $id == 1000){
                    throw new Exception("System groups cannot be deleted!");   
               }
               
               //delete the user!
               $this->db->Execute("DELETE FROM user_group WHERE id = " . $id);
               
               //log action
               $this->log->recordAction("Ajax: Deleted group ($id)");
               
            //something went wrong
            }catch(exception $e){
                //log error
                $this->log->recordError($e->getMessage());

                //do nothing
            }
            
			$this->r->html = $this->smarty->preFetch('ajax'.DIRECTORY_SEPARATOR.'deleteGroup.html');
        }
    }
?>